import 'dart:io';

import 'package:animal/utils/sputils/sp_config.dart';

///消息类型代码
enum MessageTypeEnum {
  LOGIN, // 0, "登录"
  LOGOUT, // 1, "退出"
  HEART, //2, "心跳"
  MESSAGE, //3, "聊天（群聊/单聊）"
  READ_PACKAGE, // 4, "红包"
  TRANSFER_MONEY, //5, "转帐"
  CALLBACK, //7, "回执"
  FRIEND_APPLY, //8, "好友申请"
  GROUP_INVITE, //9, "群聊邀请"
  NOTICE, //10, "消息通知"
  CARD, //11, "名片"
  GOODS, //12, "商品"
  SYSTEM_NOTICE, //13, "系统通知"
  MESSAGE_RECEIPT, //14, "消息回执"
}

///消息类型实体
class Message {
  static Message instance = Message();

  Future<int?> msType({MessageTypeEnum? type}) async {
    if (type == MessageTypeEnum.LOGIN) {
      return 0;
    } else if (type == MessageTypeEnum.LOGOUT) {
      return 1;
    } else if (type == MessageTypeEnum.HEART) {
      return 2;
    } else if (type == MessageTypeEnum.MESSAGE) {
      return 3;
    } else if (type == MessageTypeEnum.READ_PACKAGE) {
      return 4;
    } else if (type == MessageTypeEnum.TRANSFER_MONEY) {
      return 5;
    } else if (type == MessageTypeEnum.CALLBACK) {
      return 7;
    } else if (type == MessageTypeEnum.FRIEND_APPLY) {
      return 8;
    } else if (type == MessageTypeEnum.GROUP_INVITE) {
      return 9;
    } else if (type == MessageTypeEnum.NOTICE) {
      return 10;
    } else if (type == MessageTypeEnum.CARD) {
      return 11;
    } else if (type == MessageTypeEnum.GOODS) {
      return 12;
    } else if (type == MessageTypeEnum.SYSTEM_NOTICE) {
      return 13;
    } else if (type == MessageTypeEnum.MESSAGE_RECEIPT) {
      return 14;
    }
  }

  ///统一消息模板Model
  static Map messageModel({int? messageType, String? time, bool isSend = false}) {
    Map a;
    a= {"ht": messageType ?? 0, "t": SpConfig().getUserToken(), "st": time ?? DateTime.now().millisecondsSinceEpoch, "s": isSend, "snt": 0};
    return a;
  }
}

///pf 客户端平台 (windows 0、mac 1、android 2、ios 3、web 4)
///snt 服务器端通知类型（0 客户端发起消息的回调，1 服务器主动发起的消息）
